package com.zmn.plat.services.impl.channel.brand.ratio;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.zmn.plat.model.entity.channel.brand.ratio.ChannelBrandAllLevelRatioQuery;
import com.zmn.plat.model.entity.channel.brand.ratio.ChannelBrandRatio;
import com.zmn.plat.model.entity.channel.brand.ratio.ChannelBrandRatioQuery;
import com.zmn.plat.model.vo.channel.brand.ratio.ChannelBrandRatioAllLevelVo;
import com.zmn.plat.model.vo.channel.brand.ratio.ChannelBrandRatioVo;
import com.zmn.plat.persistence.interfaces.channel.brand.ratio.ChannelBrandRatioDAO;
import com.zmn.plat.services.interfaces.channel.brand.ratio.ChannelBrandRatioService;

/**
 * 类描述:渠道品牌系数管理实现类
 *
 * @author linfeng
 * @since 2020/09/02/11:20
 */
@Service
public class ChannelBrandRatioServiceImpl implements ChannelBrandRatioService {
    @Resource
    private ChannelBrandRatioDAO channelBrandRatioDAO;

    @Override
    @Cacheable(cacheNames = "redis1h", key = "'base:ratio:channelbrand:channelBrandAllLevelRatioQuery:'+#p1", unless = "#result == null")
    public ChannelBrandRatioAllLevelVo findAllLevelRatio(ChannelBrandAllLevelRatioQuery channelBrandAllLevelRatioQuery) {
        return channelBrandRatioDAO.findAllLevelRatio(channelBrandAllLevelRatioQuery);
    }

    @Override
    public List<ChannelBrandRatioVo> listPageByQuery(ChannelBrandRatioQuery query) {
        int count = channelBrandRatioDAO.countByQuery(query);
        query.setTotalCount(count);
        return channelBrandRatioDAO.listPageByQuery(query);
    }

    @Override
    public List<ChannelBrandRatio> listByQuery(ChannelBrandRatioQuery query) {
        return channelBrandRatioDAO.listByQuery(query);
    }

    @Override
    @Cacheable(cacheNames = "redis1h", key = "'price:listForFlowByBizType:channelId:'+#p0+':bizType:'+#p1", unless = "#result == null")
    public List<ChannelBrandRatio> listForFlowByBizType(Integer channelId, Integer bizType) {
        return channelBrandRatioDAO.listForFlowByBizType(channelId, bizType);
    }

    @Override
    @Cacheable(cacheNames = "redis1h", key = "'price3:listForFlow3ByChannel:channelId:'+#p0", unless = "#result == null")
    public List<Integer> listForFlow3ByChannel(Integer channelId) {
        return channelBrandRatioDAO.listForFlow3ByChannel(channelId);
    }

    @Override
    public Integer updateByKey(ChannelBrandRatio brandRatio) {
        return channelBrandRatioDAO.updateByKey(brandRatio);
    }

    @Override
    public void updateToBeEffectiveRatioBatch(List<ChannelBrandRatio> updateRatioList) {
        channelBrandRatioDAO.updateToBeEffectiveRatioBatch(updateRatioList);
    }

    @Override
    public Integer updateRatioByKeyBatch(List<ChannelBrandRatio> channelBrandRatioList) {
        return channelBrandRatioDAO.updateRatioByKeyBatch(channelBrandRatioList);
    }

    @Override
    public Integer insert(ChannelBrandRatio brandRatio) {
        return channelBrandRatioDAO.insert(brandRatio);
    }

    @Override
    public Integer insertBatch(List<ChannelBrandRatio> brandRatioList) {
        return channelBrandRatioDAO.insertBatch(brandRatioList);
    }

    @Override
    public void copyRatio(Integer sourceChannelId, Integer targetChannelId, Integer bizType, Integer priceType, Date effectiveDate, String opertor) {
        channelBrandRatioDAO.copyRatio(sourceChannelId, targetChannelId, bizType, priceType, effectiveDate, opertor);
    }

    @Override
    public void deleteByChannelIdAndBrandId(Integer channelId, Integer brandId) {
        channelBrandRatioDAO.deleteByChannelIdAndBrandId(channelId, brandId);
    }

    @Override
    public void deleteByChannelIdAndPriceTypeAndBizType(Integer channelId, Integer priceType, Integer bizType) {
        channelBrandRatioDAO.deleteByChannelIdAndPriceTypeAndBizType(channelId, priceType, bizType);
    }

    @Override
    public void deleteByChannelIdAndBrandIdsAndPriceTypeAndBizType(Integer channelId, String[] ids, Integer priceType, Integer bizType) {
        channelBrandRatioDAO.deleteByChannelIdAndBrandIdsAndPriceTypeAndBizType(channelId, ids, priceType, bizType);
    }

    @Override
    public void deleteByPrimaryKey(Integer factorId) {
        channelBrandRatioDAO.deleteByPrimaryKey(factorId);
    }

    @Override
    public void deleteByKeys(List<Integer> ratioIds) {
        channelBrandRatioDAO.deleteByKeys(ratioIds);
    }

    @Override
    public void copy(Integer originalChannelId, int targetChannelId, String operator) {

        channelBrandRatioDAO.copy(originalChannelId, targetChannelId, operator);
    }
}
